package com.stackexchange.webapis
{
	import com.stackexchange.webapis.events.StackExchangeFaultEvent;
	import com.stackexchange.webapis.events.StackExchangeResultEvent;
	
	import org.flexunit.asserts.assertNotNull;
	import org.flexunit.asserts.assertTrue;
	import org.flexunit.async.Async;
	import org.hamcrest.core.isA;

	public class CommentsTest extends BaseTest
	{
		[Test(async)]
		public function commentsGetByExistingId():void
		{
			function handleResult(event:StackExchangeResultEvent, passThroughData:Object):void
			{
				assertTrue(event.success);
				assertNotNull(event.data.comments);
				assertTrue(event.data.comments, isA(CommentList));
			}
			
			var passThroughData:Object = new Object();
		    service.comments.addEventListener(StackExchangeResultEvent.COMMENTS_GET_BY_ID, 
		               Async.asyncHandler(this, handleResult, TestConstants.timeout, passThroughData, handleTimeout), 
		               false, 0, true);
		    service.comments.getById([TestConstants.commentId1]);
		}
		
		[Test(async)]
		public function commentsGetByWrongFormatedId():void
		{
			function handleResult(event:StackExchangeFaultEvent, passThroughData:Object):void
			{
				assertNotNull(event.data);
			}
			
			var passThroughData:Object = new Object();
			service.addEventListener(StackExchangeFaultEvent.FAULT, 
				Async.asyncHandler(this, handleResult, TestConstants.timeout, passThroughData, handleTimeout), 
				false, 0, true);
			service.comments.getById([TestConstants.wrongFormatedId]);
		}
	}
}